Page({
      data:{
        isincome:true,
        incomelist:[],
        paylist:[],
        jilu:[],
        isinput:true,
        incometotal:0,
        paytotal:0,
        inputval:'',
        date:'',
        ye:'',
        jilu1:[]
      },
      click(e){
        console.log(e)
        if(e.currentTarget.dataset.name=='income'){
          this.setData({
            isincome:true
          })
        }else{
          this.setData({
            isincome:false
          })
        }
      },
      bindDateChange: function(e) {
        console.log(e, e.detail.value)
    
        this.setData({
          date: e.detail.value,
        })
      },
      add(){
        this.setData({
          isinput:!this.data.isinput
        })
      },
      confirm(e){
        console.log(e)
        let je=Number(e.detail.value)
        let incomelist=this.data.incomelist
        let paylist=this.data.paylist
        let jilu=this.data.jilu
        let jilu1=this.data.jilu1
        let ye=this.data.ye
        let inc=0
        let pay=0
        if(this.data.isincome){
          incomelist.push(je)
          inc=je
          let incometotal=incomelist.reduce((sum,v)=>{
            return sum+=v
          },0)
          this.setData({
            incomelist,
            incometotal,
            inputval:'',
            isinput:false,
            jilu
          })
          
        }else{
          paylist.push(je);
          pay=je
          let paytotal=paylist.reduce((sum,v)=>{
            return sum+=v
          },0)
          this.setData({
            paylist,
            inputval:'',
            isinput:false,
            paytotal
          })
        }
        let b=[(this.data.date).substring(0,7),inc,pay]
        ye=this.data.incometotal-this.data.paytotal
        jilu.push(b)
        for(var i=0;i<jilu.length;i++){
          if((this.data.date).substring(0,7)==jilu[i][0]&&i+1!=jilu.length){
            jilu[i][1]+=inc
            jilu[i][2]+=pay
            jilu.splice(jilu.length-1,1)
            jilu1.splice(jilu.length-1,1)
          }
        }
        jilu1=[]
        for(var j=0;j<jilu.length;j++){
          let jl=jilu[j][0]+"收入："+jilu[j][1]+"支出："+jilu[j][2]
          jilu1.push(jl)
        }
        console.log(jilu)
        this.setData({
          jilu,
          ye,
          jilu1
        })
      },
      onUnload(){
        console.log('onUnload')
        this.onHide()
    },
     onHide(){
            console.log('onHide')
            let store=[this.data.incomelist,this.data.paylist,this.data.incometotal,this.data.paytotal,this.data.date,this.data.jilu,this.data.jilu1]
            wx.setStorage({
              data:store,
              key:'money'
            })
          },
          onLoad(option){
            console.log('onLoad')
            let that=this
            wx.getStorage({
              key:'money',
              success(e){
                console.log(e)
                that.setData({
                  incomelist:e.data[0],
                  paylist:e.data[1],
                  incometotal:e.data[2],
                  paytotal:e.data[3],
                  date:e.data[4],
                  jilu1:e.data[6]
                })
              }
            })
          }
        })